package cn.bgs.service.impl;

import cn.bgs.dao.commodityMapper;
import cn.bgs.dao.itemUserMapper;
import cn.bgs.pojo.commodity;
import cn.bgs.pojo.itemUser;
import cn.bgs.service.commodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ProjectName: bei
 * @Package: cn.bgs.service.impl
 * @ClassName: commodityServiceImpl
 * @Author: Administrator
 * @Description:
 * @Date: 2021/9/14 0014 8:58
 * @Version: 1.0
 */
@Service
public class commodityServiceImpl implements commodityService {
    @Autowired
    private commodityMapper commodityMapper;
    @Autowired
    private itemUserMapper itemUserMapper;
    @Override
    public List<commodity> findGoods() {
        return commodityMapper.findGoods();
    }

    @Override
    public List<commodity> findShop() {
        return commodityMapper.findShop();
    }



    @Override
    public itemUser selOneUser(String id,String stuId) {
        itemUser user = itemUserMapper.selectByPrimaryKey(id);
        Integer count =null;
        if(user==null){
            commodityMapper.updateShop(id,stuId);
        }
        if(user!=null){
            count = user.getCount()+1;
            commodityMapper.updateByPrimaryKey(id,count);
        }
        return user;
    }

    @Override
    public List<itemUser> itemUserFind() {
        return itemUserMapper.itemUserFind();
    }
}
